package iss.java;

import iss.java.list.MyList;
import iss.java.list.Node;

/**
 * Created by wenke on 2016/9/16.
 */

public class Main_A {
    public static void main(String[] args) {
        // TODO: Implement a multithreaded test case against requirement A.
    	
    	MyList list = new MyList();
    	list.insert(list.getHead(), 10);
    	
    	Node node = list.getHead().getNext();
    	
    	Thread ta = new Thread() {
    		public void run() {
    			synchronized (node) {
    				int data = node.getData();
    				data += 10;
    				node.setData(data);
    				System.out.println(node.getData());
    			}
    		}
    	};
    	
    	Thread tb = new Thread() {
    		public void run() {
    			synchronized (node) {
    				int data = node.getData();
    				data++;
    				node.setData(data);
    				System.out.println(node.getData());
    			}
    		}
    	};
    	
    	Thread tc = new Thread() {
    		public void run() {
    			synchronized (node) {
    				int data = node.getData();
    				data--;
    				node.setData(data);
    				System.out.println(node.getData());
    			}
    		}
    	};
    	
    	ta.start();
    	tb.start();
    	tc.start();
    	
    	
    }
}
